import Duck from 'extensible-duck'
import produce from 'immer'

export default new Duck({
  namespace: 'label',
  store: 'config',
  types: ['Toggle_FULL_SCREEN', 'SET_FULL_SCREEN'],
  initialState: { fullScreen: false },
  reducer: produce((draft, action, duck) => {
    switch (action.type) {
      case duck.types.Toggle_FULL_SCREEN:
        draft.fullScreen = !draft.fullScreen
        break
      case duck.types.SET_FULL_SCREEN:
        draft.fullScreen = action.value
        break
      default:
        break
    }
  }),
  selectors: {
    fullScreen: state => state.config.fullScreen,
  },
  creators: duck => ({
    toggleFullScreen: () => ({ type: duck.types.Toggle_FULL_SCREEN }),
    setFullScreen: value => ({ type: duck.types.SET_FULL_SCREEN, value }),
  }),
})
